package com.KMGSoftworks.ShoppingList;

import android.net.Uri;
import android.provider.BaseColumns;

public final class ShoppingList {
	public static final String AUTHORITY = "com.KMGSoftworks.provider.ShoppingList";
	
	private ShoppingList(){}
	
	public static final class List implements BaseColumns{
		private List(){}
		
		public static final String TABLE_NAME = "lists";
		
		private static final String SCHEME = "content://";
		private static final String PATH_LISTS = "/lists";
		private static final String PATH_LIST_ID = "/lists/";
		
		public static final int LIST_ID_PATH_POSITION = 1;
		public static final Uri CONTENT_URI = Uri.parse(SCHEME + AUTHORITY + PATH_LISTS);
		
		public static final Uri CONTENT_ID_URI_BASE = Uri.parse(SCHEME + AUTHORITY + PATH_LIST_ID);
		public static final Uri CONTENT_ID_URI_PATTERN = Uri.parse(SCHEME + AUTHORITY + PATH_LIST_ID + "/#");
		
		public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.KMGSoftworks.list";
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.KMGSoftworks.list";
        public static final String DEFAULT_SORT_ORDER = "name";

        public static final String COLUMN_NAME_NAME = "name";
        public static final String COLUMN_NAME_COUNT = "count";
        
    	public static final int COLUMN_INDEX_NAME = 1;
    	public static final int COLUMN_INDEX_COUNT = 2;
    	
    	public static final String SELECTION = List.COLUMN_NAME_NAME + " = ?";
    	public static final String SELECTION_ID = List._ID + " = ?";

        
        public static final String[] LIST_PROJECTION = new String[] {
        	ShoppingList.List._ID,
        	ShoppingList.List.COLUMN_NAME_NAME,
        	ShoppingList.List.COLUMN_NAME_COUNT
        };

	}

	public static final class Item implements BaseColumns{
		private Item(){}
		
		public static final String TABLE_NAME = "items";
		
		private static final String SCHEME = "content://";
		private static final String PATH_ITEMS = "/items";
		private static final String PATH_ITEMS_ID = "/items/";
		
		public static final int ID_PATH_POSITION = 1;
		public static final Uri CONTENT_URI = Uri.parse(SCHEME + AUTHORITY + PATH_ITEMS);
		
		public static final Uri CONTENT_ID_URI_BASE = Uri.parse(SCHEME + AUTHORITY + PATH_ITEMS_ID);
		public static final Uri CONTENT_ID_URI_PATTERN = Uri.parse(SCHEME + AUTHORITY + PATH_ITEMS_ID + "/#");
		
		public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.KMGSoftworks.items";
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.KMGSoftworks.items";
        public static final String DEFAULT_SORT_ORDER = "itemName";

        public static final String COLUMN_NAME_ID = "_id";
        public static final String COLUMN_NAME_ITEM_NAME = "itemName";
        
        public static final int COLUMN_INDEX_ID = 0;
    	public static final int COLUMN_INDEX_ITEM_NAME = 1;

    	public static final String SELECTION = Item.COLUMN_NAME_ITEM_NAME + " = ?";
        
        public static final String[] ITEM_PROJECTION = new String[] {
        	_ID,
        	COLUMN_NAME_ITEM_NAME,
        };

	}

	public static final class ListItem implements BaseColumns{
		private ListItem(){}

		public static final String TABLE_NAME = "listitems";
								
		private static final String SCHEME = "content://";
		private static final String PATH_LIST_ITEMS = "/listitems";
		private static final String PATH_LIST_ITEMS_ID = "/listitems/";
		
		public static final int ID_PATH_POSITION = 1;
		public static final Uri CONTENT_URI = Uri.parse(SCHEME + AUTHORITY + PATH_LIST_ITEMS);
		
		public static final Uri CONTENT_ID_URI_BASE = Uri.parse(SCHEME + AUTHORITY + PATH_LIST_ITEMS_ID);
		public static final Uri CONTENT_ID_URI_PATTERN = Uri.parse(SCHEME + AUTHORITY + PATH_LIST_ITEMS_ID + "/#");
		
		public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.KMGSoftworks.listitems";
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.KMGSoftworks.listitems";

        public static final String COLUMN_NAME_LIST_ID = "listID";
        public static final String COLUMN_NAME_ITEM_ID = "itemID";
        public static final String COLUMN_NAME_COUNT = "count";
        
        public static final int COLUMN_INDEX_ID = 0;
        public static final int COLUMN_INDEX_LIST_ID = 1;
    	public static final int COLUMN_INDEX_ITEM_ID = 2;
    	public static final int COLUMN_INDEX_COUNT = 3;

    	public static final String SELECTION_BY_LIST_ID = ListItem.COLUMN_NAME_LIST_ID + " = ?";
    	public static final String SELECTION_BY_ITEM_ID = ListItem.COLUMN_NAME_ITEM_ID + " = ?";
        
        public static final String[] PROJECTION = new String[] {
        	COLUMN_NAME_LIST_ID,
        	COLUMN_NAME_ITEM_ID,
        	COLUMN_NAME_COUNT
        };

	}
	
	private interface ListItemsItemsQuery {

		public static final String TABLE = ListItem.TABLE_NAME + " JOIN " +
			Item.TABLE_NAME + " ON (" +
			ListItem.COLUMN_NAME_ITEM_ID + " = " +
			Item._ID + ")";

		public static final String[] PROJECTION = new String[]{
			ListItem.COLUMN_NAME_LIST_ID,
			ListItem.COLUMN_NAME_ITEM_ID,
			Item.COLUMN_NAME_ITEM_NAME,
			ListItem.COLUMN_NAME_COUNT
		};
		
		public static final int LIST_ID 	= 0;
		public static final int ITEM_ID 	= 1;
		public static final int ITEM_NAME 	= 2;
		public static final int ITEM_COUNT 	= 3;
		
		
	}

}
